#include <iostream>
#include <unistd.h>
#include <fcntl.h>

using std::cout;
using std::endl;


int main(int args, char *argv[])
{
    pid_t pid;
    int fd = open("../data/hello.txt", O_RDONLY);
    char buf[6];
    pid = fork();
    if(pid == 0){
        printf("child:\n");
        read(fd, buf, 5);
        lseek(fd, 1, SEEK_CUR);
        printf("read: %s\n",buf);
    }else{
        sleep(1);
        printf("parent:\n");
        read(fd, buf, 5);
        printf("read: %s\n",buf);
    }
    close(fd);
    return 0;
}